home *** CD-ROM | disk | FTP | other *** search
/ Wayzata's Best of Shareware PC/Windows 1 / Wayzata's Best of Shareware for PC-Windows - Release 1 - Wayzata Technology (1993).iso / mac / DOS / GRAPHICS / LISS151 / LISSAJOU.H < prev    next >
C/C++ Source or Header  |  1992-04-20  |  7KB  |  197 lines

  1. /* *****************
  2.    LISSAJOU.H
  3.        This file contains all the function prototypes and global
  4.        variables for LISSAJOU.C
  5.  
  6.        Program originally written by Dan Farmer using algorithms from
  7.        Clifford Pickover.  Converted from QuickBasic to C by Aaron C. Caba.
  8.        See Scientific American January 1991 and Omni February 1990 for
  9.        excellent examples by Pickover.
  10.  
  11.  
  12. History:
  13.  
  14.   03/09/92 ACC Move #includes and #defines to this file
  15.   02/11/92 ACC Major rearangement of all code:
  16.                move all field manipulation prototypes to FIELD.C
  17.                clean up header files so only necessary stuff is in each
  18.   12/18/91 ACC Move all defines, and global var's to DEFINES.H
  19.   12/10/91 ACC Move all prototypes, defines, and global var's to
  20.                LISSAJOU.H
  21. */
  22.  
  23. /*=========================== Defined constants ========================*/
  24.  
  25. #ifndef _LISSAJOU
  26. #define _LISSAJOU
  27.  
  28. #define BOLT_HT               255   /* Y pos of GUI bolts in EGA        */
  29. #define CLIP_ON                 1   /* Clip graphics outside window     */
  30. #define CLIP_OFF                0   /* don't clip outside graph. window */
  31. #define PARMFIELDS             10   /* Number of main fields            */
  32. #define VIEWER                300   /* for screen preview only (low value="wide angle" perspective) */
  33.  
  34. #include <alloc.h>
  35. #include <conio.h>
  36. #include <ctype.h>
  37. #include <graphics.h>
  38. #include <math.h>
  39. #include <stdio.h>
  40. #include <stdlib.h>
  41. #include <string.h>
  42. #include "defines.h"    /* constants and enum's                 */
  43. #include "error_fn.h"   /* error handling routine               */
  44.  
  45. /*  The following variables are public to all sub-functions in lissajou.c */
  46.  
  47. char *label[]= {        /* Note:  label and field_default must be */      
  48.     "     R Value = ",  /* declared before the #include "field.h" */
  49.     "     A Value = ",
  50.     "     B Value = ",
  51.     "  X-Exponent = ",
  52.     "  Y-Exponent = ",
  53.     "  Z-Exponent = ",
  54.     "  Sphere Rad = ",
  55.     "# of Spheres = ",
  56.     "View (X,Y,Z) = ",
  57.     "Method (1-5) = ",
  58.     "Angle to rotate: ",
  59.     "",
  60.     "",
  61.     "",
  62.     "",
  63. };
  64. char *field_default[] = {
  65.     "100",
  66.     "0.10",
  67.     "0.25",
  68.     "1",
  69.     "1",
  70.     "1",
  71.     "8",
  72.     "500",
  73.     "Z",
  74.     "1",
  75.     "45",
  76.     "",
  77.     "",
  78.     "",
  79. };
  80.  
  81. /*========================== Global variables ==============================*/
  82. #include "field.h"
  83.  
  84. struct field_struct field[MAXFIELDS];
  85.  
  86. int wintop, winbottom, winleft, winright,   /* coords of graphics window    */
  87.     cols, rows,                             /* max rows and cols on screen  */
  88.     xcenter, ycenter,                       /* center of screen             */
  89.     winxcenter, winycenter,                 /* center of drawing window     */
  90.     maxcolors=14,                           /* number of colors in following array */
  91.     colors[]= {                             /* look-up table of all the     */
  92.         EGA_DARKGRAY,     EGA_YELLOW,       /*   EGA colors                 */
  93.         EGA_BLUE,         EGA_LIGHTBLUE,
  94.         EGA_GREEN,        EGA_LIGHTGREEN,
  95.         EGA_CYAN,         EGA_LIGHTCYAN,
  96.         EGA_RED,          EGA_LIGHTRED,
  97.         EGA_MAGENTA,      EGA_LIGHTMAGENTA,
  98.         EGA_BROWN,        EGA_WHITE};
  99.  
  100. int   k, median_index;  /* for quicksort()                  */
  101. float median;
  102.  
  103. int parm_field;         /* is TRUE for fields 1-PARMFIELDS, */
  104.                         /* FALSE for the others             */
  105.  
  106.  
  107.  
  108. /*========================== Function Prototypes =======================*/
  109.  
  110. /* return (x,y,z) of point at time 't'  */
  111. void algo1(int t, int r, float a, float b,
  112.            int exponent_x, int exponent_y, int exponent_z,
  113.            float *x, float *y, float *z);
  114. void algo2(int t, int r, float a, float b,
  115.            int exponent_x, int exponent_y, int exponent_z,
  116.            float *x, float *y, float *z);
  117. void algo3(int t, int r, float a, float b,
  118.            int exponent_x, int exponent_y, int exponent_z,
  119.            float *x, float *y, float *z);
  120. void algo4(int t, int r, float a, float b,
  121.            int exponent_x, int exponent_y, int exponent_z,
  122.            float *x, float *y, float *z);
  123. void algo5(int t, int r, float a, float b,
  124.            int exponent_x, int exponent_y, int exponent_z,
  125.            float *x, float *y, float *z);
  126.  
  127. /* Make sure data is O.K., or assign default if not O.K. */
  128. void check_data(char *data[]);
  129.  
  130. /* Clean-up the graphics screen, return to text mode */
  131. void clean_up_graph(void);
  132.  
  133. /* return value of component 'comp' from structure 'a' */
  134. #define component(a,comp) ( (!strcmp(comp,"X")) ? ((a)->x) : \
  135.                            ((!strcmp(comp,"Y")) ? ((a)->y) : ((a)->z)) )
  136.  
  137. /* draw coordinate axes in the display window */
  138. void disp_axes(char *axis);
  139.  
  140. /* Draw gui-looking windows, logo, and print field labels */
  141. void disp_bkground(void);
  142.  
  143. /* display the spheres in the viewing window */
  144. void disp_spheres(struct queue_type queue[], int index[], 
  145.                   int number, char *data[]);
  146.  
  147. /* Edit the paramaters.  Take in array of data.
  148.    Return [EXIT | NO_EXIT] */
  149. int  edit_parms(char *data[]);
  150.  
  151. /* Draw a gui looking panel from (wleft,wtop) to (wright,wbottom),
  152.    'toggle' lines deep.  'toggle'>0 outset, <0 inset */
  153. void guipanel(int wleft, int wtop, int wright, int wbottom, int toggle);
  154.  
  155. /* Draw a gui looking bolt at (x,y) with radius 'r',
  156.    'toggle' lines deep.  'toggle'>0 for outset, <0 for inset */
  157. void guibolt(int x, int y, int r, int toggle);
  158.  
  159. /* Initalize the 'field' variable with:
  160.                 field label
  161.                       length
  162.                       screen (x,y) position
  163.                       type */
  164. void initfield(char *data[]);
  165.  
  166. /* --- Sort the circles on 'axis', from most distant to closest for simple
  167.        "hidden line removal".  Farthest will be drawn first and overlapped
  168.        by the nearer circles.
  169.        Parms: queue = array of values needed sorting.
  170.               index = single dimension array of integers indexing queue().
  171.               left  = lowest index #.
  172.               right = highest index #.
  173. */
  174. void quicksort(struct queue_type queue[], int *index, 
  175.                const int left, const int right, char *axis);
  176.  
  177. /* rotate points to get a different viewing angle
  178.    Parms: queue     = array of values
  179.           num       = number of spheres to rotate
  180.           angle_str = default angle to rotate
  181.           r         = radius of the spheres
  182. */
  183. void rotate_fig(struct queue_type queue[], int num,
  184.                 char *angle_str, char *axis);
  185.  
  186. /* Scale the radius of the displayed spheres to simulate perspective
  187.    Return the scaled radius */
  188. int  scaled_radius(int r, int z);
  189.  
  190. /* Print "msg"+"(Y or N)" on bottom panel
  191.    Return TRUE for Y or FALSE for N */
  192. int  verify(char *msg);
  193.  
  194. #endif
  195.  
  196. /* end-of-file lissajou.h */
  197.